home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / AMIGAFFS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  5KB  |  229 lines

  1. #ifndef AMIGAFFS_H
  2. #define AMIGAFFS_H
  3.  
  4. #include <asm/byteorder.h>
  5. #include <linux/types.h>
  6.  
  7. /* AmigaOS allows file names with up to 30 characters length.
  8.  * Names longer than that will be silently truncated. If you
  9.  * want to disallow this, comment out the following #define.
  10.  * Creating filesystem objects with longer names will then
  11.  * result in an error (ENAMETOOLONG).
  12.  */
  13. /*#define AFFS_NO_TRUNCATE */
  14.  
  15. /* Ugly macros make the code more pretty. */
  16.  
  17. #define GET_END_PTR(st,p,sz)         ((st *)((char *)(p)+((sz)-sizeof(st))))
  18. #define AFFS_GET_HASHENTRY(data,hashkey) be32_to_cpu(((struct dir_front *)data)->hashtable[hashkey])
  19. #define AFFS_BLOCK(data,ino,blk)     ((struct file_front *)data)->blocks[AFFS_I2HSIZE(ino)-1-(blk)]
  20.  
  21. #define FILE_END(p,i)    GET_END_PTR(struct file_end,p,AFFS_I2BSIZE(i))
  22. #define ROOT_END(p,i)    GET_END_PTR(struct root_end,p,AFFS_I2BSIZE(i))
  23. #define DIR_END(p,i)    GET_END_PTR(struct dir_end,p,AFFS_I2BSIZE(i))
  24. #define LINK_END(p,i)    GET_END_PTR(struct hlink_end,p,AFFS_I2BSIZE(i))
  25. #define ROOT_END_S(p,s)    GET_END_PTR(struct root_end,p,(s)->s_blocksize)
  26. #define DATA_FRONT(bh)    ((struct data_front *)(bh)->b_data)
  27. #define DIR_FRONT(bh)    ((struct dir_front *)(bh)->b_data)
  28.  
  29. /* Only for easier debugging if need be */
  30. #define affs_bread    bread
  31. #define affs_brelse    brelse
  32.  
  33. #ifdef __LITTLE_ENDIAN
  34. #define BO_EXBITS    0x18UL
  35. #elif defined(__BIG_ENDIAN)
  36. #define BO_EXBITS    0x00UL
  37. #else
  38. #error Endianness must be known for affs to work.
  39. #endif
  40.  
  41. #define FS_OFS        0x444F5300
  42. #define FS_FFS        0x444F5301
  43. #define FS_INTLOFS    0x444F5302
  44. #define FS_INTLFFS    0x444F5303
  45. #define FS_DCOFS    0x444F5304
  46. #define FS_DCFFS    0x444F5305
  47. #define MUFS_FS        0x6d754653   /* 'muFS' */
  48. #define MUFS_OFS    0x6d754600   /* 'muF\0' */
  49. #define MUFS_FFS    0x6d754601   /* 'muF\1' */
  50. #define MUFS_INTLOFS    0x6d754602   /* 'muF\2' */
  51. #define MUFS_INTLFFS    0x6d754603   /* 'muF\3' */
  52. #define MUFS_DCOFS    0x6d754604   /* 'muF\4' */
  53. #define MUFS_DCFFS    0x6d754605   /* 'muF\5' */
  54.  
  55. #define T_SHORT        2
  56. #define T_LIST        16
  57. #define T_DATA        8
  58.  
  59. #define ST_LINKFILE    -4
  60. #define ST_FILE        -3
  61. #define ST_ROOT        1
  62. #define ST_USERDIR    2
  63. #define ST_SOFTLINK    3
  64. #define ST_LINKDIR    4
  65.  
  66. struct root_front
  67. {
  68.   s32 primary_type;
  69.   s32 spare1[2];
  70.   s32 hash_size;
  71.   s32 spare2;
  72.   u32 checksum;
  73.   s32 hashtable[0];
  74. };
  75.  
  76. struct root_end
  77. {
  78.   s32 bm_flag;
  79.   s32 bm_keys[25];
  80.   s32 bm_extend;
  81.   struct DateStamp dir_altered;
  82.   u8 disk_name[40];
  83.   struct DateStamp disk_altered;
  84.   struct DateStamp disk_made;
  85.   s32 spare1[3];
  86.   s32 secondary_type;
  87. };
  88.  
  89. struct dir_front
  90. {
  91.   s32 primary_type;
  92.   s32 own_key;
  93.   s32 spare1[3];
  94.   u32 checksum;
  95.   s32 hashtable[0];
  96. };
  97.  
  98. struct dir_end
  99. {
  100.   s32 spare1;
  101.   s16 owner_uid;
  102.   s16 owner_gid;
  103.   u32 protect;
  104.   s32 spare2;
  105.   u8 comment[92];
  106.   struct DateStamp created;
  107.   u8 dir_name[32];
  108.   s32 spare3[2];
  109.   s32 link_chain;
  110.   s32 spare4[5];
  111.   s32 hash_chain;
  112.   s32 parent;
  113.   s32 spare5;
  114.   s32 secondary_type;
  115. };
  116.  
  117. struct file_front
  118. {
  119.   s32 primary_type;
  120.   s32 own_key;
  121.   s32 block_count;
  122.   s32 unknown1;
  123.   s32 first_data;
  124.   u32 checksum;
  125.   s32 blocks[0];
  126. };
  127.  
  128. struct file_end
  129. {
  130.   s32 spare1;
  131.   s16 owner_uid;
  132.   s16 owner_gid;
  133.   u32 protect;
  134.   s32 byte_size;
  135.   u8 comment[92];
  136.   struct DateStamp created;
  137.   u8 file_name[32];
  138.   s32 spare2;
  139.   s32 original;    /* not really in file_end */
  140.   s32 link_chain;
  141.   s32 spare3[5];
  142.   s32 hash_chain;
  143.   s32 parent;
  144.   s32 extension;
  145.   s32 secondary_type;
  146. };
  147.  
  148. struct hlink_front
  149. {
  150.   s32 primary_type;
  151.   s32 own_key;
  152.   s32 spare1[3];
  153.   u32 checksum;
  154. };
  155.  
  156. struct hlink_end
  157. {
  158.   s32 spare1;
  159.   s16 owner_uid;
  160.   s16 owner_gid;
  161.   u32 protect;
  162.   u8 comment[92];
  163.   struct DateStamp created;
  164.   u8 link_name[32];
  165.   s32 spare2;
  166.   s32 original;
  167.   s32 link_chain;
  168.   s32 spare3[5];
  169.   s32 hash_chain;
  170.   s32 parent;
  171.   s32 spare4;
  172.   s32 secondary_type;
  173. };
  174.  
  175. struct slink_front
  176. {
  177.   s32 primary_type;
  178.   s32 own_key;
  179.   s32 spare1[3];
  180.   s32 checksum;
  181.   u8    symname[288];    /* depends on block size */
  182. };
  183.  
  184. struct data_front
  185. {
  186.   s32 primary_type;
  187.   s32 header_key;
  188.   s32 sequence_number;
  189.   s32 data_size;
  190.   s32 next_data;
  191.   s32 checksum;
  192.   u8 data[488];    /* depends on block size */
  193. };
  194.  
  195. /* Permission bits */
  196.  
  197. #define FIBF_OTR_READ        0x8000
  198. #define FIBF_OTR_WRITE        0x4000
  199. #define FIBF_OTR_EXECUTE    0x2000
  200. #define FIBF_OTR_DELETE        0x1000
  201. #define FIBF_GRP_READ        0x0800
  202. #define FIBF_GRP_WRITE        0x0400
  203. #define FIBF_GRP_EXECUTE    0x0200
  204. #define FIBF_GRP_DELETE        0x0100
  205.  
  206. #define FIBF_SCRIPT        0x0040
  207. #define FIBF_PURE        0x0020        /* no use under linux */
  208. #define FIBF_ARCHIVE        0x0010        /* never set, always cleared on write */
  209. #define FIBF_READ        0x0008        /* 0 means allowed */
  210. #define FIBF_WRITE        0x0004        /* 0 means allowed */
  211. #define FIBF_EXECUTE        0x0002        /* 0 means allowed, ignored under linux */
  212. #define FIBF_DELETE        0x0001        /* 0 means allowed */
  213.  
  214. #define FIBF_OWNER        0x000F        /* Bits pertaining to owner */
  215.  
  216. #define AFFS_UMAYWRITE(prot)    (((prot) & (FIBF_WRITE|FIBF_DELETE)) == (FIBF_WRITE|FIBF_DELETE))
  217. #define AFFS_UMAYREAD(prot)    ((prot) & FIBF_READ)
  218. #define AFFS_UMAYEXECUTE(prot)    ((prot) & FIBF_EXECUTE)
  219. #define AFFS_GMAYWRITE(prot)    (((prot)&(FIBF_GRP_WRITE|FIBF_GRP_DELETE))==\
  220.                             (FIBF_GRP_WRITE|FIBF_GRP_DELETE))
  221. #define AFFS_GMAYREAD(prot)    ((prot) & FIBF_GRP_READ)
  222. #define AFFS_GMAYEXECUTE(prot)    ((prot) & FIBF_EXECUTE)
  223. #define AFFS_OMAYWRITE(prot)    (((prot)&(FIBF_OTR_WRITE|FIBF_OTR_DELETE))==\
  224.                             (FIBF_OTR_WRITE|FIBF_OTR_DELETE))
  225. #define AFFS_OMAYREAD(prot)    ((prot) & FIBF_OTR_READ)
  226. #define AFFS_OMAYEXECUTE(prot)    ((prot) & FIBF_EXECUTE)
  227.  
  228. #endif
  229.